/*
 * HwAbstraction.h
 *
 *  Created on: 22.09.2011
 *      Author: windows97
 */

#ifndef HWABSTRACTION_H_
#define HWABSTRACTION_H_

#define DCF77_INT_CLEARFLAGS	  ((1<<ISC11) | (1<<ISC10))
#define DCF77_INT_FALLING_EDGE  (1<<ISC11)
#define DCF77_INT_RISING_EDGE   ((1<<ISC11) | (1<<ISC10))
#define INT0_INT_CLEARFLAGS     ((1<<ISC01) | (1<<ISC00))
#define INT0_FALLING_EDGE       (1<<ISC01)
#define INT0_RISING_EDGE        ((1<<ISC01) | (1<<ISC00))
#define DCF77_INT           	INT1_vect
#define KEYPORT             PORTC
#define KEYDDR              DDRC
#define KEYPIN              PINC
#define KEY0                PC5
#define INT_CONTROL         EICRA//MCUCR

#define LIGHT_INT           INT0_vect
#define LIGHT_OC_INT        TIMER1_COMPB_vect

#define SET_LIGHT_INT       EIMSK   |= (1 << INT0)
#define CLR_LIGHT_INT       EIMSK   &= ~(1 << INT0)

#define SET_LIGHT_OC_INT    TIMSK1  |= (1 << OCIE1B)
#define CLR_LIGHT_OC_INT    TIMSK1  &= ~(1 << OCIE1B)

#define SET_TRIAC_OUT_PIN   PORTC |= (1 << PC4)
#define CLR_TRIAC_OUT_PIN   PORTC &= ~(1 << PC4)
#define TOG_TRIAC_OUT_PIN   PORTC ^= (1 << PC4)

#define SET_SOUND_OUT_PIN   PORTD |=  (1 << PD4)
#define CLR_SOUND_OUT_PIN   PORTD &= ~(1 << PD4)
#define TOG_SOUND_OUT_PIN   PORTD ^=  (1 << PD4)

#define SET_DCF_ENABLE_PIN  PORTD &= ~(1 << PD5)
#define CLR_DCF_ENABLE_PIN  PORTD |=  (1 << PC5)
#define TOG_DCF_ENABLE_PIN  PORTD ^=  (1 << PD5)

/*
MR 10 master reset (active LOW)
Q0 15 parallel data output
 */

/* SHCP - shift register clock input */
#define SET_SHCP_PIN
#define CLR_SHCP_PIN
#define TOG_SHCP_PIN

/* STCP - storage register clock input */
#define SET_STCP_PIN
#define CLR_STCP_PIN
#define TOG_STCP_PIN

/* OE - output enable input (active LOW) */
#define SET_OE_PIN
#define CLR_OE_PIN
#define TOG_OE_PIN

/* DS - serial data input */
#define SET_DS_PIN
#define CLR_DS_PIN
#define TOG_DS_PIN


/* to abstract from makefile during development */
#ifndef F_CPU
  #define CPU_FREQUENCY       10000000
#else
  #define CPU_FREQUENCY       F_CPU
#endif

#endif /* HWABSTRACTION_H_ */
